package org.darkforest.common.util;

/**
 * Created by valentina on 15/3/6.
 */
public class MathUtil {

    /**
     * 获取int型随机数，如果超出int范围则返回空
     *
     * @param length 随机数长度
     * @return
     */
    public static Integer getRandom(int length) {
        if (length <= 0 || length > 10) {
            return null;
        }
        double ram = Math.ceil(Math.random() * Math.pow(10, length));

        return (int) ram;
    }


    public static void main(String[] args) {
        System.out.print(MathUtil.getRandom(6));
    }
}
